<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateEntryorderProductsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('entryorder_products', function (Blueprint $table) {
            $table->id();
            $table->unsignedBigInteger('entryorder_id')->comment('入库单ID');
            $table->unsignedBigInteger('product_id')->comment('产品ID');
            $table->integer('quantity')->comment('数量');
            $table->decimal('price', 10, 2)->comment('价格');
            $table->timestamps();

            $table->unique(['entryorder_id', 'product_id']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('entryorder_products');
    }
}
